import random
play = ["石头","剪刀","布"]
i = 0
player_score = 0
robot_score = 0
RED = "\033[31m"
RESET = "\033[0m"
while i < 5:
    person = int(input("请输入:1.石头 2.剪刀 3.布\n"))
    robot = random.choice(play)
    if person == 1:
        if robot == "石头":
            print("玩家出石头，机器人出石头，平局")
            i -= 1
        elif robot == "剪刀":
            print("玩家出石头，机器人出剪刀，玩家胜")
            player_score += 1
            if player_score == 3:
                break
        elif robot == "布":
            print("玩家出石头，机器人出布，机器人胜")
            robot_score += 1
            if robot_score == 3:
                break
    elif person == 2:
        if robot == "石头":
            print("玩家出剪刀，机器人出石头，机器人胜")
            robot_score += 1
            if robot_score == 3:
                break
        elif robot == "剪刀":
            print("玩家出剪刀，机器人出剪刀，平局")
            i -= 1
        elif robot == "布":
            print("玩家出剪刀，机器人出布，玩家胜")
            player_score += 1
            if player_score == 3:
                break
    elif person == 3:
        if robot == "石头":
            print("玩家出布，机器人出石头，玩家胜")
            player_score += 1
            if player_score == 3:
                break
        elif robot == "剪刀":
            print("玩家出布，机器人出剪刀，机器人胜")
            robot_score += 1
            if robot_score == 3:
                break
        elif robot == "布":
            print("玩家出布，机器人出布，平局")
            i -= 1
    else :
        print("输入不正确请重新输入：")
        i -= 1
    print(f"{RED}当前积分\n玩家：%s分 机器人：%s分{RESET}"%(player_score, robot_score))
    i += 1
print(f"{RED}当前积分\n玩家：%s分 机器人：%s分{RESET}"%(player_score, robot_score))